package com.yu.subject.common.exception;

import com.yu.subject.common.entity.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author 路亚
 * @version 0.1
 * @className GlobalExceptionHandle
 * @description
 * @date 2024/12/23 20:22
 * @since jdk11
 */
@RestControllerAdvice
public class GlobalExceptionHandle {

    @ExceptionHandler
    public Result exception(JavaSmException e) {
        Result result = new Result();
        result.setSuccess(false);
        result.setCode(e.getCodeAndMessage().getCode());
        result.setMessage(e.getCodeAndMessage().getMessage());
        return result;
    }
}
